package dao;

import java.sql.Connection;
import java.sql.SQLException;

import dao.oracle.JenisKeretaApiDao;
import dao.oracle.KoordinatDao;
import dao.oracle.KeretaApiDao;
import dao.oracle.RuteDao;

public class DAOFactory {
	private Connection conn;
	private static DAOFactory instance;
	
	private DAOFactory() throws SQLException{
		conn = ResourceManager.getConnection();
	}
	
	public static DAOFactory getInstance() throws SQLException{
		if(instance == null){
			instance = new DAOFactory();
		}
		return instance;
	}
	public static KoordinatDao createKoordinatDao() throws SQLException{
		return new KoordinatDao(DAOFactory.getInstance());
	}
	public static KeretaApiDao createKeretaApiDao() throws SQLException{
		return new KeretaApiDao(DAOFactory.getInstance());
	}
	public static JenisKeretaApiDao createJenisKeretaApiDao() throws SQLException{
		return new JenisKeretaApiDao(DAOFactory.getInstance());
	}
	public static RuteDao createRuteDao() throws SQLException{
		return new RuteDao(DAOFactory.getInstance());
	}
	public Connection getConnection(){
		return conn;
	}
}
